import { ThemeContext } from "../context/theme-context";

//函数组件如何使用context?
function HomeBanner() {
  
  return (
    <div>
      <h2>HomeBanner</h2>
      {/* 使用consumer，往context.consumer的children中传入一个回调函数, 返回要展示的内容*/}
      <ThemeContext.Consumer>
        {
          value => {
            return <h2>{value.color}</h2>
          }
        }
      </ThemeContext.Consumer>
    </div>
   );
}

export default HomeBanner;